<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>鱼水狩·发布帖子</title>
    <link rel="shortcut icon" type="image/x-icon" href="/assets/img/favicon.ico">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- CSS here -->
    <link rel="stylesheet" href="/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="/assets/css/owl.carousel.min.css">
    <link rel="stylesheet" href="/assets/css/slicknav.css">
    <link rel="stylesheet" href="/assets/css/flaticon.css">
    <link rel="stylesheet" href="/assets/css/animate.min.css">
    <link rel="stylesheet" href="/assets/css/magnific-popup.css">
    <link rel="stylesheet" href="/assets/css/fontawesome-all.min.css">
    <link rel="stylesheet" href="/assets/css/themify-icons.css">
    <link rel="stylesheet" href="/assets/css/slick.css">
    <link rel="stylesheet" href="/assets/css/nice-select.css">
    <link rel="stylesheet" href="/assets/css/style.css">
    <!--富文本编辑器wangEditor-->
    <link href="/wangEditor/wangEditor.min.css" rel="stylesheet">
    <link href="/wangEditor/w-e-icon.woff" rel="stylesheet">
    <script src="/wangEditor/wangEditor.min.js"></script>
    <link rel="stylesheet" href="/tao/mine.css">
    <script src="/tao/config.js"></script>
</head>
<body background="/assets/img/gallery/section_bg04.jpg">
<!--              前置渲染js              -->
<script th:inline="javascript">
    let tokenSign = [[${token}]];
    if (tokenSign != null && tokenSign.length > 20)
        window.sessionStorage.setItem('token', JSON.stringify(tokenSign));
</script>
<!-- Preloader Start -->
<div id="preloader-active">
    <div class="preloader d-flex align-items-center justify-content-center">
        <div class="preloader-inner position-relative">
            <div class="preloader-circle"></div>
            <div class="preloader-img pere-text">
                <img src="/assets/img/logo/logo.png" alt="QAQ">
            </div>
        </div>
    </div>
</div>
<!-- Preloader Start -->
<header>
    <!-- Header Start -->
    <div class="header-area">
        <div class="main-header  header-sticky">
            <div class="container-fluid">
                <div class="row align-items-center">
                    <!-- Logo -->
                    <div class="col-xl-2 col-lg-2 col-md-1">
                        <div class="logo row">
                            <a href="/index"><img src="/assets/img/logo/logo.png" alt="QAQ"></a>
                        </div>
                    </div>
                    <div class="col-xl-10 col-lg-10 col-md-10">
                        <div class="menu-main d-flex align-items-center justify-content-end">
                            <!-- Main-menu -->
                            <div class="main-menu f-right d-none d-lg-block">
                                <nav>
                                    <ul id="navigation">
                                        <li><a href="/index" id="url03">首页</a></li>
                                        <li><a href="/resource">资源</a></li>
                                        <li><a href="/followed/token">关注</a></li>
                                        <li><a href="/news/token">消息</a></li>
                                        <li><a href="/my/token" id="url01">我的</a></li>
                                        <li><a href="/editor/token" id="url02">发布帖子</a></li>
                                    </ul>
                                </nav>
                            </div>
                            <div id="isAuth" style="display: inline">
                                <div class="header-right-btn f-right d-none d-xl-block ml-20" >
                                    <a href="/login" class="btn header-btn">登录</a>
                                    <a href="/register" class="btn header-btn">注册</a>
                                </div>
                            </div>
                            <!--              导航栏渲染js              -->
                            <script> navStarter() </script>
                        </div>
                    </div>
                    <span style="font-size: xx-small;color: darkgrey" th:text="'访问量:'+${visitorNum}"></span>
                    <!-- Mobile Menu -->
                    <div class="col-12">
                        <div class="mobile_menu d-block d-lg-none"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Header End -->
</header>
<div class="jumbotron">
    <p class="text-center" style="font-size: large;font-weight: bolder">发布帖子</p>
    <div class="container">
        <div class="blog_right_sidebar">
            <aside class="single_sidebar_widget search_widget "  style="background:#e9ecef">
                        <div class="input-group mb-3">
                            <div class="input-group-append">
                                <button class="btns">主题</button>
                            </div>
                            <input type="text" class="form-control" placeholder='(鱼水狩太棒啦)' id="blogTitle" value="鱼水狩太棒啦"
                                   onfocus="this.placeholder = ''"
                                   onblur="this.placeholder = '(鱼水狩太棒啦)'">
                        </div>
            </aside>
        </div>
        <div id="editor">
            <p>欢迎使用鱼水狩博客</p>
        </div>
        <div style="margin-left: 88%"><button class="btn btn-primary btn-lg" id="btnGenCode" role="button" type="submit" onclick="send()">发布 »</button></div>
    </div>
</div>
<footer>
    <!-- Footer Start-->
    <div class="footer-area">
        <div class="container">
            <div class="footer-top footer-padding">
                <div class="row justify-content-center">
                    <div class="col-lg-6">
                        <div class="footer-top-cap text-center">
                            <img src="/assets/img/logo/logo.png" alt="QAQ">
                            <span><a href="#">245149633@qq.com</a></span>
                            <p>以上是作者邮箱,有意见可联系作者</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="footer-bottom">
                <div class="row d-flex justify-content-between align-items-center">
                    <div class="col-xl-9 col-lg-8">
                        <div class="footer-copy-right">
                            <p>
                                Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | This webSite is made with <i class="fa fa-heart" aria-hidden="true"></i> by <a href="http://wytcloud.top" target="_blank">鱼水狩</a>
                                <a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备2021062754号</a>
                            </p>
                            <p>
                                Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved | Thanks for view template provider,<a href="https://colorlib.com" target="_blank">Colorlib</a>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Footer End-->
</footer>

<!-- JS here -->
<!-- All JS Custom Plugins Link Here here -->
<script src="/assets/js/vendor/modernizr-3.5.0.min.js"></script>
<!-- Jquery, Popper, Bootstrap -->
<script src="/assets/js/vendor/jquery-1.12.4.min.js"></script>
<script src="/assets/js/popper.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<!-- Jquery Mobile Menu -->
<script src="/assets/js/jquery.slicknav.min.js"></script>

<!-- Jquery Slick , Owl-Carousel Plugins -->
<script src="/assets/js/owl.carousel.min.js"></script>
<script src="/assets/js/slick.min.js"></script>
<!-- One Page, Animated-HeadLin -->
<script src="/assets/js/wow.min.js"></script>
<script src="/assets/js/animated.headline.js"></script>
<script src="/assets/js/jquery.magnific-popup.js"></script>

<!-- Nice-select, sticky -->
<script src="/assets/js/jquery.nice-select.min.js"></script>
<script src="/assets/js/jquery.sticky.js"></script>

<!-- contact js -->
<script src="/assets/js/contact.js"></script>
<script src="/assets/js/jquery.form.js"></script>
<script src="/assets/js/jquery.validate.min.js"></script>
<script src="/assets/js/mail-script.js"></script>
<script src="/assets/js/jquery.ajaxchimp.min.js"></script>

<!-- Jquery Plugins, main Jquery -->
<script src="/assets/js/plugins.js"></script>
<script src="/assets/js/main.js"></script>

</body>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#editor')
    // 配置服务器端地址
    editor.customConfig.uploadImgServer = '/uploadBlogImg'
    let userToken = this.sessionStorage.getItem("token");
    editor.customConfig.uploadImgParams = {
        userToken: userToken.substring(1,userToken.length - 1)
    };
    //配置指定文件名
    editor.customConfig.uploadFileName = 'blogImg'
    //如果图片不大，可以用base64存储
    //editor.customConfig.uploadImgShowBase64 = true
    editor.customConfig.menus = [
        'head',  // 标题
        'bold',  // 粗体
        'fontSize',  // 字号
        'italic',  // 斜体
        'underline',  // 下划线
        'strikeThrough',  // 删除线
        'foreColor',  // 文字颜色
        'backColor',  // 背景颜色
        'link',  // 插入链接
        'list',  // 列表
        'justify',  // 对齐方式
        'quote',  // 引用
        'image',  // 插入图片
        'table',  // 表格
        'video',  // 插入视频
        'code',  // 插入代码
        'undo',  // 撤销
        'redo'  // 重复
    ]
    editor.create()

    function send() {
        let content = editor.txt.html();
        let title = document.getElementById("blogTitle").value
        let token = this.sessionStorage.getItem("token")
        if (title.length==0)
            alert("主题不能为空哦")
        else{
            $.post({
                url:"/publishBlog",
                data:{
                    "content":content,
                    "title":title,
                    "userToken": token.substring(1,token.length - 1)
                },
                success:function (res) {
                    let url = WEB_URL;
                    if (token != null && token.length > 20)
                        url += '/index/' + token.substring(1,token.length - 1)
                    window.location.href = url;
                }
            })
        }
    }
</script>
</html>